﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BasicCMS.Logging.Impl
{
    /// <summary>
    /// 基于log4net的工厂
    /// </summary>
    [ComponentRegistry(Lifetime.Singleton, "logger", "log4net")]
    public class Log4NetFactory : ILogFactory
    {
        static Log4NetFactory()
        {
            log4net.Config.XmlConfigurator.Configure();
        }

        public Log4NetFactory()
        {
        }

        public ILog GetLogger(string name)
        {
            return new Log4NetLogger(log4net.LogManager.GetLogger(name));
        }

        public ILog GetLogger(Type type)
        {
            return new Log4NetLogger(log4net.LogManager.GetLogger(type));
        }

        public ILog GetLogger<T>()
        {
            return GetLogger(typeof(T));
        }
    }
}
